package com.fan.leetcode;

import java.util.Arrays;

/**
 * 1833. 雪糕的最大数量
 *
 * @author ZhangFan
 * @since 2021/8/3 下午 10:22
 */
public class Question1833 {
    public int maxIceCream(int[] costs, int coins) {
        Arrays.sort(costs);
        int sum = 0, count = 0;
        for (int cost : costs) {
            if (sum + cost <= coins) {
                sum += cost;
                count++;
            }
        }
        return count;
    }
}
